#ifndef APPLICATIONCONNECTOR_H
#define APPLICATIONCONNECTOR_H

#include <QObject>
#include <QTcpSocket>

class Socket;

class ApplicationConnector : public QObject
{
    Q_OBJECT
public:
    ApplicationConnector(Socket *clientSocket, QObject *parent = 0);

    /**
     * @brief ApplicationConnector::connectApplication connects the client to the application represented by socket
     * @param auid is the AUID of the application to connect to
     * @param socket is the socket connected to the application
     */
    void connectApplication(int auid, Socket *socket);

public Q_SLOTS:
    /**
     * @brief ApplicationConnector::processClientData processes the data coming from the client and send it to the right application according to the AUID (Application Unique Identifier)
     * @param data is the received bulk of data
     */
    void processClientData(QByteArray);

    /**
     * @brief ApplicationConnector::processApplicationData processes the data coming from the application like notifications or response and send it to the good client
     * @param data is the received data from the application
     */
    void processApplicationData(QByteArray);

private:
    Socket *p_client;
    QMap<int, Socket*> v_auidApplicationMap;
    QMap<Socket*, int> v_applicationAuidMap;
};

#endif // APPLICATIONCONNECTOR_H
